home *** CD-ROM | disk | FTP | other *** search
/ Digital Background Bonanza / Digital Background Bonanza - Disc 1.iso / pc / DBB1.swf / scripts / __Packages / mx / video / FPADManager.as < prev    next >
Encoding:
Text File  |  2007-03-09  |  4.4 KB  |  141 lines

  1. class mx.video.FPADManager
  2. {
  3.    var _owner;
  4.    var _uriParam;
  5.    var _parseResults;
  6.    var _url;
  7.    var xml;
  8.    var rtmpURL;
  9.    static var version = "1.0.1.10";
  10.    static var shortVersion = "1.0.1";
  11.    static var ELEMENT_NODE = 1;
  12.    static var TEXT_NODE = 3;
  13.    function FPADManager(owner)
  14.    {
  15.       this._owner = owner;
  16.    }
  17.    function connectXML(urlPrefix, uriParam, urlSuffix, uriParamParseResults)
  18.    {
  19.       this._uriParam = uriParam;
  20.       this._parseResults = uriParamParseResults;
  21.       this._url = urlPrefix + "uri=" + this._parseResults.protocol;
  22.       if(this._parseResults.serverName != undefined)
  23.       {
  24.          this._url += "/" + this._parseResults.serverName;
  25.       }
  26.       if(this._parseResults.portNumber != undefined)
  27.       {
  28.          this._url += ":" + this._parseResults.portNumber;
  29.       }
  30.       if(this._parseResults.wrappedURL != undefined)
  31.       {
  32.          this._url += "/?" + this._parseResults.wrappedURL;
  33.       }
  34.       this._url += "/" + this._parseResults.appName;
  35.       this._url += urlSuffix;
  36.       this.xml = new XML();
  37.       this.xml.onLoad = mx.utils.Delegate.create(this,this.xmlOnLoad);
  38.       this.xml.load(this._url);
  39.       return false;
  40.    }
  41.    function xmlOnLoad(success)
  42.    {
  43.       try
  44.       {
  45.          if(!success)
  46.          {
  47.             this._owner.helperDone(this,false);
  48.          }
  49.          else
  50.          {
  51.             var _loc5_ = this.xml.firstChild;
  52.             var _loc8_ = false;
  53.             while(_loc5_ != null)
  54.             {
  55.                if(_loc5_.nodeType == mx.video.FPADManager.ELEMENT_NODE)
  56.                {
  57.                   _loc8_ = true;
  58.                   if(_loc5_.nodeName.toLowerCase() == "fpad")
  59.                   {
  60.                      break;
  61.                   }
  62.                }
  63.                _loc5_ = _loc5_.nextSibling;
  64.             }
  65.             if(!_loc8_)
  66.             {
  67.                throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"URL: \"" + this._url + "\" No root node found; if url is for an flv it must have .flv extension and take no parameters");
  68.             }
  69.             if(_loc5_ == null)
  70.             {
  71.                throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"URL: \"" + this._url + "\" Root node not fpad");
  72.             }
  73.             var _loc7_ = undefined;
  74.             var _loc6_ = 0;
  75.             while(_loc6_ < _loc5_.childNodes.length)
  76.             {
  77.                var _loc3_ = _loc5_.childNodes[_loc6_];
  78.                if(_loc3_.nodeType == mx.video.FPADManager.ELEMENT_NODE)
  79.                {
  80.                   if(_loc3_.nodeName.toLowerCase() == "proxy")
  81.                   {
  82.                      var _loc2_ = 0;
  83.                      while(_loc2_ < _loc3_.childNodes.length)
  84.                      {
  85.                         var _loc4_ = _loc3_.childNodes[_loc2_];
  86.                         if(_loc4_.nodeType == mx.video.FPADManager.TEXT_NODE)
  87.                         {
  88.                            _loc7_ = this.trim(_loc4_.nodeValue);
  89.                            break;
  90.                         }
  91.                         _loc2_ = _loc2_ + 1;
  92.                      }
  93.                      break;
  94.                   }
  95.                }
  96.                _loc6_ = _loc6_ + 1;
  97.             }
  98.             if(_loc7_ == undefined || _loc7_ == "")
  99.             {
  100.                throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"URL: \"" + this._url + "\" fpad xml requires proxy tag.");
  101.             }
  102.             this.rtmpURL = this._parseResults.protocol + "/" + _loc7_ + "/?" + this._uriParam;
  103.             this._owner.helperDone(this,true);
  104.          }
  105.       }
  106.       catch(err:Error)
  107.       {
  108.          this._owner.helperDone(this,false);
  109.          throw err;
  110.       }
  111.    }
  112.    function trim(str)
  113.    {
  114.       var _loc2_ = 0;
  115.       while(_loc2_ < str.length)
  116.       {
  117.          var _loc1_ = str.charAt(_loc2_);
  118.          if(_loc1_ != " " && _loc1_ != "\t" && _loc1_ != "\r" && _loc1_ != "\n")
  119.          {
  120.             break;
  121.          }
  122.          _loc2_ = _loc2_ + 1;
  123.       }
  124.       if(_loc2_ >= str.length)
  125.       {
  126.          return "";
  127.       }
  128.       var _loc4_ = str.length - 1;
  129.       while(_loc4_ > _loc2_)
  130.       {
  131.          _loc1_ = str.charAt(_loc4_);
  132.          if(_loc1_ != " " && _loc1_ != "\t" && _loc1_ != "\r" && _loc1_ != "\n")
  133.          {
  134.             break;
  135.          }
  136.          _loc4_ = _loc4_ - 1;
  137.       }
  138.       return str.slice(_loc2_,_loc4_ + 1);
  139.    }
  140. }
  141.